name: Snowpark Conda Build Test

on:
  push:
    branches:
      - "develop"
  pull_request:
    types: [opened, synchronize, reopened]

# Avoid duplicate workflows on same branch
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build_snowpark_conda_package:
    runs-on: ubuntu-latest

    defaults:
      run:
        shell: bash --login -eo pipefail {0}

    steps:
      - name: Checkout Streamlit code
        uses: actions/checkout@v4
        with:
          persist-credentials: false
          submodules: "recursive"
          fetch-depth: 2
      - name: Set build config env vars
        uses: ./.github/actions/build_info
      # We need to install Python 3.9 here because it's the latest version
      # supported by the miniconda installer as of 2022/10/11.
      - name: Set up Python 3.9
        uses: actions/setup-python@v5
        with:
          python-version: "3.9"
      - name: Setup virtual env
        uses: ./.github/actions/make_init
      - name: Install conda and conda-build
        env:
          MINICONDA_RELEASE: "Miniconda3-py39_4.12.0-Linux-x86_64"
        run: |
          curl -sO "https://repo.anaconda.com/miniconda/${MINICONDA_RELEASE}.sh"
          bash "${MINICONDA_RELEASE}.sh" -b
          conda install conda-build=3.28.4
      - name: Build Snowpark Conda Package - Fast
        timeout-minutes: 120
        run: |
          sudo apt install rsync
          SNOWPARK_CONDA_BUILD=1 BUILD_AS_FAST_AS_POSSIBLE=1 make conda-package
